﻿// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.


using IdentityServer4;
using IdentityServer4.Models;
using System.Collections.Generic;

namespace IdentityServer
{
    public static class Config
    {
        public static IEnumerable<IdentityResource> IdentityResources =>
            new IdentityResource[]
            { 
                new IdentityResources.OpenId(),
                new IdentityResources.Profile()
            };

        public static IEnumerable<ApiScope> ApiScopes =>
            new ApiScope[]
            { 
                new ApiScope("api1","MyApi"),
                new ApiScope("api2","MyApi2")
            };

        public static IEnumerable<Client> Clients =>
            new Client[] 
            { 
                new Client
                { 
                    ClientId="client",
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets = 
                    { 
                        new Secret("secret".Sha256())
                    },
                    AllowedScopes = {"api1" }
                },
                new Client
                {
                    ClientId="client2",
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets =
                    {
                        new Secret("secret2".Sha256())
                    },
                    AllowedScopes = {"api2" }
                },
                new Client
                { 
                    ClientId="mvc",
                    ClientSecrets={new Secret("secret".Sha256()) },
                    AllowedGrantTypes = GrantTypes.Code,
                    RedirectUris={ "https://localhost:5002/signin-oidc" },
                    PostLogoutRedirectUris={ "https://localhost:5002/signout-callback-oidc" },
                    AllowOfflineAccess = true,
                    AllowedScopes=new List<string>
                    {
                        IdentityServerConstants.StandardScopes.Profile,
                        IdentityServerConstants.StandardScopes.OpenId,
                        "api1"
                    }
                },
                new Client
                {
                    ClientId="js",
                    ClientName="JavaScript Client",
                    ClientSecrets={new Secret("secret".Sha256()) },
                    AllowedGrantTypes = GrantTypes.Code,
                    RequireClientSecret = false,
                    RedirectUris={ "https://localhost:5003/callback.html"},
                    PostLogoutRedirectUris={ "https://localhost:5003/index.html"  },
                    AllowedCorsOrigins={ "https://localhost:5003"},
                    AllowedScopes=new List<string>
                    {
                        IdentityServerConstants.StandardScopes.Profile,
                        IdentityServerConstants.StandardScopes.OpenId,
                        "api1"
                    }
                }
            };
    }
}